<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{:session('cp.cpsysname')}--服务商管理平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="{:config('webconfig.description');}">
    <meta name="keywords" content="{:config('webconfig.keywords');}">
    <meta name="author" content="runoob">
    <link rel="stylesheet" href="__STATIC_URL__/static/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="__STATIC_URL__/static/css/index.css"/>
    <script src="__STATIC_URL__/static/jquery/2.2.1/jquery.min.js"></script>
    <script src="__STATIC_URL__/static/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="__STATIC_URL__/static/layer/layer.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

{include file='public/header'/}
<!------------------导航-------------------------->
<section>
    {include file='public/left'/}
    <!--------------------------主要内容区域------------------------------------->
    <div class="content">
        <div class="page-heading mgl15 mgr15">
            <ul class="breadcrumb">
                <li>当前位置是&nbsp;:&nbsp;</li>
                <li><a href="#">微信管理</a></li>
                <li class="active" style="color: #02b87f;">微信版本设置</li>
            </ul>
        </div>
        <div class="panel panel-default mgl15 mgr15">
            <div class="panel-body">

                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">

                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">草稿箱</h3>
                            </div>
                            <table class="table table-bordered">

                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>发布来源</th>
                                    <th>创建时间</th>
                                    <th>版本号</th>
                                    <th>草稿箱ID</th>
                                    <th>发布人</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="data" id="vo" key="k"}
                                <tr>
                                    <td>{$k}</td>
                                    <td>{$vo['source_miniprogram']}</td>
                                    <td>{$vo['create_time']|date="Y-m-d H:i:s",###}</td>
                                    <td>{$vo['user_version']}</td>
                                    <td>{$vo['draft_id']}</td>
                                    <td>{$vo['developer']}</td>
                                    <td>{$vo['user_desc']}</td>
                                    <td><a onclick="tjmbk({$vo['draft_id']})">添加到模板库</a></td>
                                </tr>
                                {/volist}

                                </tbody>
                            </table>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">模板库</h3>
                            </div>
                            <table class="table table-bordered">

                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>发布来源</th>
                                    <th>创建时间</th>
                                    <th>版本号</th>
                                    <th>模板库ID</th>
                                    <th>发布人</th>
                                    <th>备注</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                {volist name="data2" id="vo" key="k"}
                                <tr>
                                    <td>{$k}</td>
                                    <td>{$vo['source_miniprogram']}</td>
                                    <td>{$vo['create_time']|date="Y-m-d H:i:s",###}</td>
                                    <td>{$vo['user_version']}</td>
                                    <td>{$vo['template_id']}</td>
                                    <td>{$vo['developer']}</td>
                                    <td>{$vo['user_desc']}</td>
                                    <td><a onclick="delmbk({$vo['template_id']})">删除</a></td>
                                </tr>
                                {/volist}

                                </tbody>
                            </table>
                        </div>
                        <div class="panel panel-default">
                            <div class="panel-heading">
                                <h3 class="panel-title">设置当前上线模板</h3>
                            </div>
                            <div class="panel-body">
                                <form class="form-horizontal" name="form" id="frm3" style="max-width: 900px;">
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">模板ID：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="template_id"
                                                   value="{$xcxset['template_id']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">小程序入口页：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="extpages"
                                                   value="{$xcxset['extpages']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">用户版本号：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="user_version"
                                                   value="{$xcxset['user_version']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">服务器域名：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="weburl"
                                                   value="{$xcxset['weburl']}">
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-sm-3">版本介绍：</label>
                                        <div class="col-sm-9">
                                            <input type="text" class="form-control" placeholder="" name="user_desc"
                                                   value="{$xcxset['user_desc']}">
                                        </div>
                                    </div>
                                    <div class="form-group text-center">
                                        <span class="btn btn-default" id="sethy">设置</span>
                                    </div>
                                </form>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        {include file='public/footer'/}
    </div>
</section>

</body>

<script>
     function delmbk(obj){
         layer.confirm('是否设置？', {
             btn: ['确认', '取消'] //按钮
         }, function () {
             $.ajax({
                 url: "{:url('xcxsysset/del_tpl')}",
                 type: "post",
                 data: {
                     "draft_id":obj,
                 },
                 success: function (data) {
                     if (data.code == "0") {

                         layer.msg("设置成功", {icon: 1});
                         setTimeout("window.location.href=window.location.href",2000);
                         return false;
                     } else {
                         layer.alert("操作失败  "+data.code+"   "+data.message, {icon: 7});
                     }
                 }
             })
         }, function () {
             layer.msg('您已取消!', {
                 time: 500, //20s后自动关闭
             });
         });
     }
     function tjmbk(obj){
         layer.confirm('是否设置？', {
             btn: ['确认', '取消'] //按钮
         }, function () {
             $.ajax({
                 url: "{:url('xcxsysset/addtpl')}",
                 type: "post",
                 data: {
                     "draft_id":obj,
                 },
                 success: function (data) {
                     console.log(data);
                     if (data.code == "0") {

                         layer.msg("设置成功", {icon: 1});
                         setTimeout("window.location.href=window.location.href",2000);
                         return false;
                     } else {
                         layer.alert("操作失败  "+data.code+"   "+data.message, {icon: 7});
                     }
                 }
             })
         }, function () {
             layer.msg('您已取消!', {
                 time: 500, //20s后自动关闭
             });
         });
     }
    $(function () {
        $("#sethy").click(function () {
            layer.confirm('是否设置？', {
                btn: ['确认', '取消'] //按钮
            }, function () {
                $.ajax({
                    url: "{:url('xcxsysset/set_tpl')}",
                    type: "post",
                    data: $('#frm3').serialize(),
                    success: function (data) {
                        console.log(data);
                        if (data.code == "0") {

                            layer.msg("设置成功", {icon: 1});
                            return false;
                        } else {
                            layer.alert("设置失败", {icon: 7});
                        }
                    }
                })
            }, function () {
                layer.msg('您已取消!', {
                    time: 500, //20s后自动关闭
                });
            });

        })

    })
</script>
</html>


